





<!DOCTYPE html>
<html class="writer-html5" lang="zh-CN" >
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>tvm.rpc &mdash; tvm 0.8.dev1982 文档</title>
  

  
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/gallery.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/css/tlcpack_theme.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../../_static/tvm-logo-square.png"/>
  

  
  
  
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/underscore.js"></script>
        <script src="../../../_static/doctools.js"></script>
        <script src="../../../_static/translations.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    
    <script type="text/javascript" src="../../../_static/js/tlcpack_theme.js"></script>
    <link rel="index" title="索引" href="../../../genindex.html" />
    <link rel="search" title="搜索" href="../../../search.html" />
    <link rel="next" title="tvm.micro" href="micro.html" />
    <link rel="prev" title="tvm.auto_scheduler" href="auto_scheduler.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    
<header class="header">
    <div class="innercontainer">
      <div class="headerInner d-flex justify-content-between align-items-center">
          <div class="headerLogo">
               <a href="https://tvm.apache.org/"><img src=https://tvm.apache.org/assets/images/logo.svg alt="logo"></a>
          </div>

          <div id="headMenu" class="headerNav">
            <button type="button" id="closeHeadMenu" class="navCloseBtn"><img src="../../../_static/img/close-icon.svg" alt="Close"></button>
             <ul class="nav">
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/community>Community</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/download>Download</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/vta>VTA</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/blog>Blog</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/docs>Docs</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmconf.org>Conference</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://github.com/apache/tvm/>Github</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmchinese.github.io/declaration_zh_CN.html>About-Translators</a>
                </li>
             </ul>
               <div class="responsivetlcdropdown">
                 <button type="button" class="btn-link">
                   ASF
                 </button>
                 <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                 </ul>
               </div>
          </div>
            <div class="responsiveMenuIcon">
              <button type="button" id="menuBtn" class="btn-menu"><img src="../../../_static/img/menu-icon.svg" alt="Menu Icon"></button>
            </div>

            <div class="tlcDropdown">
              <div class="dropdown">
                <button type="button" class="btn-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  ASF
                </button>
                <div class="dropdown-menu dropdown-menu-right">
                  <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                  </ul>
                </div>
              </div>
          </div>
       </div>
    </div>
 </header>
 
    <nav data-toggle="wy-nav-shift" class="wy-nav-side fixed">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../../index.html">
          

          
            
            <img src="../../../_static/tvm-logo-small.png" class="logo" alt="Logo"/>
          
          </a>

          
            
            
                <div class="version">
                  0.8.dev1982
                </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption" role="heading"><span class="caption-text">如何开始</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../install/index.html">安装 TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../contribute/index.html">贡献者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">用户引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../tutorial/index.html">User Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../how_to/index.html">How To Guides</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">开发者引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/tutorial/index.html">Developer Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/how_to/how_to.html">开发者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">架构指南</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../arch/index.html">Design and Architecture</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">主题引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../topic/microtvm/index.html">microTVM：裸机使用TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../topic/vta/index.html">VTA: Versatile Tensor Accelerator</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">参考指南</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../langref/index.html">语言参考</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Python API</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="runtime.html">tvm.runtime</a></li>
<li class="toctree-l2"><a class="reference internal" href="ndarray.html">tvm.runtime.ndarray</a></li>
<li class="toctree-l2"><a class="reference internal" href="error.html">tvm.error</a></li>
<li class="toctree-l2"><a class="reference internal" href="ir.html">tvm.ir</a></li>
<li class="toctree-l2"><a class="reference internal" href="ir.html#module-tvm.instrument">tvm.instrument</a></li>
<li class="toctree-l2"><a class="reference internal" href="ir.html#module-tvm.transform">tvm.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="target.html">tvm.target</a></li>
<li class="toctree-l2"><a class="reference internal" href="tir.html">tvm.tir</a></li>
<li class="toctree-l2"><a class="reference internal" href="tir.html#module-tvm.tir.transform">tvm.tir.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="tir.html#tvm-tir-analysis">tvm.tir.analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="tir.html#module-tvm.tir.stmt_functor">tvm.tir.stmt_functor</a></li>
<li class="toctree-l2"><a class="reference internal" href="te.html">tvm.te</a></li>
<li class="toctree-l2"><a class="reference internal" href="te.html#module-tvm.te.hybrid">tvm.te.hybrid</a></li>
<li class="toctree-l2"><a class="reference internal" href="driver.html">tvm.driver</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/index.html">tvm.relay</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/frontend.html">tvm.relay.frontend</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/nn.html">tvm.relay.nn</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/vision.html">tvm.relay.vision</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/image.html">tvm.relay.image</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/transform.html">tvm.relay.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/analysis.html">tvm.relay.analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/backend.html">tvm.relay.backend</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/dataflow_pattern.html">tvm.relay.dataflow_pattern</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/testing.html">tvm.relay.testing</a></li>
<li class="toctree-l2"><a class="reference internal" href="autotvm.html">tvm.autotvm</a></li>
<li class="toctree-l2"><a class="reference internal" href="auto_scheduler.html">tvm.auto_scheduler</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">tvm.rpc</a></li>
<li class="toctree-l2"><a class="reference internal" href="micro.html">tvm.micro</a></li>
<li class="toctree-l2"><a class="reference internal" href="contrib.html">tvm.contrib</a></li>
<li class="toctree-l2"><a class="reference internal" href="graph_executor.html">tvm.contrib.graph_executor</a></li>
<li class="toctree-l2"><a class="reference internal" href="topi.html">tvm.topi</a></li>
<li class="toctree-l2"><a class="reference internal" href="vta/index.html">vta</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../links.html">Other APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../publications.html">Publications</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../genindex.html">索引</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
      
      <nav class="wy-nav-top" aria-label="top navigation" data-toggle="wy-nav-top">
        
            <div class="togglemenu">

            </div>
            <div class="nav-content">
              <!-- tvm -->
              Table of content
            </div>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        

          




















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../index.html">Docs</a> <span class="br-arrow">></span></li>
        
          <li><a href="index.html">Python API</a> <span class="br-arrow">></span></li>
        
      <li>tvm.rpc</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../../../_sources/reference/api/python/rpc.rst.txt" rel="nofollow"> <img src="../../../_static//img/source.svg" alt="viewsource"/></a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="module-tvm.rpc">
<span id="tvm-rpc"></span><h1>tvm.rpc<a class="headerlink" href="#module-tvm.rpc" title="永久链接至标题">¶</a></h1>
<p>Lightweight TVM RPC module.</p>
<p>RPC enables connect to a remote server, upload and launch functions.
This is useful to for cross-compile and remote testing,
The compiler stack runs on local server, while we use RPC server
to run on remote runtime which don’t have a compiler available.</p>
<p>The test program compiles the program on local server,
upload and run remote RPC server, get the result back to verify correctness.</p>
<p><strong>类：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.rpc.Server" title="tvm.rpc.Server"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Server</span></code></a>([host, port, port_end, is_proxy, …])</p></td>
<td><p>Start RPC server on a separate process.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.rpc.RPCSession" title="tvm.rpc.RPCSession"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RPCSession</span></code></a>(sess)</p></td>
<td><p>RPC Client session module</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.rpc.LocalSession" title="tvm.rpc.LocalSession"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LocalSession</span></code></a>()</p></td>
<td><p>RPCSession interface backed by local environment.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.rpc.PopenSession" title="tvm.rpc.PopenSession"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PopenSession</span></code></a>(binary)</p></td>
<td><p>RPCSession interface backed by popen.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.rpc.TrackerSession" title="tvm.rpc.TrackerSession"><code class="xref py py-obj docutils literal notranslate"><span class="pre">TrackerSession</span></code></a>(addr)</p></td>
<td><p>Tracker client session.</p></td>
</tr>
</tbody>
</table>
<p><strong>函数：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.rpc.connect" title="tvm.rpc.connect"><code class="xref py py-obj docutils literal notranslate"><span class="pre">connect</span></code></a>(url, port[, key, session_timeout, …])</p></td>
<td><p>Connect to RPC Server</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.rpc.connect_tracker" title="tvm.rpc.connect_tracker"><code class="xref py py-obj docutils literal notranslate"><span class="pre">connect_tracker</span></code></a>(url, port)</p></td>
<td><p>Connect to a RPC tracker</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.rpc.with_minrpc" title="tvm.rpc.with_minrpc"><code class="xref py py-obj docutils literal notranslate"><span class="pre">with_minrpc</span></code></a>(compile_func[, server, runtime])</p></td>
<td><p>Attach the compiler function with minrpc related options.</p></td>
</tr>
</tbody>
</table>
<dl class="py class">
<dt class="sig sig-object py" id="tvm.rpc.Server">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.rpc.</span></span><span class="sig-name descname"><span class="pre">Server</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">host</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'0.0.0.0'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">port</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">9091</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">port_end</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">9199</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">is_proxy</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tracker_addr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">key</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">load_library</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">custom_addr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">silent</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">no_fork</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">server_init_callback</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.Server" title="永久链接至目标">¶</a></dt>
<dd><p>Start RPC server on a separate process.</p>
<p>This is a simple python implementation based on multi-processing.
It is also possible to implement a similar C based server with
TVM runtime which does not depend on the python.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>host</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The host url of the server.</p></li>
<li><p><strong>port</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The port to be bind to</p></li>
<li><p><strong>port_end</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The end port to search</p></li>
<li><p><strong>is_proxy</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a><em>, </em><em>optional</em>) – Whether the address specified is a proxy.
If this is true, the host and port actually corresponds to the
address of the proxy server.</p></li>
<li><p><strong>tracker_addr</strong> (<em>Tuple</em><em> (</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>) </em><em>, </em><em>optional</em>) – The address of RPC Tracker in tuple(host, ip) format.
If is not None, the server will register itself to the tracker.</p></li>
<li><p><strong>key</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The key used to identify the device type in tracker.</p></li>
<li><p><strong>load_library</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – List of additional libraries to be loaded during execution.</p></li>
<li><p><strong>custom_addr</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – Custom IP Address to Report to RPC Tracker</p></li>
<li><p><strong>silent</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a><em>, </em><em>optional</em>) – Whether run this server in silent mode.</p></li>
<li><p><strong>no_fork</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a><em>, </em><em>optional</em>) – Whether forbid fork in multiprocessing.</p></li>
<li><p><strong>server_init_callback</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Callable" title="tvm.relay.dataflow_pattern.Callable"><em>Callable</em></a><em>, </em><em>optional</em>) – Additional initialization function when starting the server.</p></li>
</ul>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>The RPC server only sees functions in the tvm namespace.
To bring additional custom functions to the server env, you can use server_init_callback.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">server_init_callback</span><span class="p">():</span>
    <span class="kn">import</span> <span class="nn">tvm</span>
    <span class="c1"># must import mypackage here</span>
    <span class="kn">import</span> <span class="nn">mypackage</span>

    <span class="n">tvm</span><span class="o">.</span><span class="n">register_func</span><span class="p">(</span><span class="s2">&quot;function&quot;</span><span class="p">,</span> <span class="n">mypackage</span><span class="o">.</span><span class="n">func</span><span class="p">)</span>

<span class="n">server</span> <span class="o">=</span> <span class="n">rpc</span><span class="o">.</span><span class="n">Server</span><span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="n">server_init_callback</span><span class="o">=</span><span class="n">server_init_callback</span><span class="p">)</span>
</pre></div>
</div>
</div>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.rpc.Server.terminate" title="tvm.rpc.Server.terminate"><code class="xref py py-obj docutils literal notranslate"><span class="pre">terminate</span></code></a>()</p></td>
<td><p>Terminate the server process</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.Server.terminate">
<span class="sig-name descname"><span class="pre">terminate</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.Server.terminate" title="永久链接至目标">¶</a></dt>
<dd><p>Terminate the server process</p>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.rpc.connect">
<span class="sig-prename descclassname"><span class="pre">tvm.rpc.</span></span><span class="sig-name descname"><span class="pre">connect</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">url</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">port</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">key</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">session_timeout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">session_constructor_args</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.connect" title="永久链接至目标">¶</a></dt>
<dd><p>Connect to RPC Server</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>url</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The url of the host</p></li>
<li><p><strong>port</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The port to connect to</p></li>
<li><p><strong>key</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – Additional key to match server</p></li>
<li><p><strong>session_timeout</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a><em>, </em><em>optional</em>) – The duration of the session in seconds, allows server to kill
the connection when duration is longer than this value.
When duration is zero, it means the request must always be kept alive.</p></li>
<li><p><strong>session_constructor_args</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a>) – List of additional arguments to passed as the remote session constructor.
The first element of the list is always a string specifying the name of
the session constructor, the following args are the positional args to that function.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>sess</strong> – The connected session.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.rpc.RPCSession" title="tvm.rpc.RPCSession">RPCSession</a></p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<p>Normal usage
.. code-block:: python</p>
<blockquote>
<div><p>client = rpc.connect(server_url, server_port, server_key)</p>
</div></blockquote>
<p>Session_constructor can be used to customize the session in the remote
The following code connects to a remote internal server via a proxy
by constructing another RPCClientSession on the proxy machine and use that
as the serving session of the proxy endpoint.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">client_via_proxy</span> <span class="o">=</span> <span class="n">rpc</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span>
    <span class="n">proxy_server_url</span><span class="p">,</span> <span class="n">proxy_server_port</span><span class="p">,</span> <span class="n">proxy_server_key</span><span class="p">,</span>
    <span class="n">session_constructor_args</span><span class="o">=</span><span class="p">[</span>
        <span class="s2">&quot;rpc.Connect&quot;</span><span class="p">,</span> <span class="n">internal_url</span><span class="p">,</span> <span class="n">internal_port</span><span class="p">,</span> <span class="n">internal_key</span><span class="p">])</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.rpc.connect_tracker">
<span class="sig-prename descclassname"><span class="pre">tvm.rpc.</span></span><span class="sig-name descname"><span class="pre">connect_tracker</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">url</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">port</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.connect_tracker" title="永久链接至目标">¶</a></dt>
<dd><p>Connect to a RPC tracker</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>url</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The url of the host</p></li>
<li><p><strong>port</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – The port to connect to</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>sess</strong> – The connected tracker session.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.rpc.TrackerSession" title="tvm.rpc.TrackerSession">TrackerSession</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.rpc.RPCSession">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.rpc.</span></span><span class="sig-name descname"><span class="pre">RPCSession</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sess</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.RPCSession" title="永久链接至目标">¶</a></dt>
<dd><p>RPC Client session module</p>
<p>Do not directly create the obhect, call connect</p>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.rpc.RPCSession.system_lib" title="tvm.rpc.RPCSession.system_lib"><code class="xref py py-obj docutils literal notranslate"><span class="pre">system_lib</span></code></a>()</p></td>
<td><p>Get system-wide library module.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.rpc.RPCSession.get_function" title="tvm.rpc.RPCSession.get_function"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_function</span></code></a>(name)</p></td>
<td><p>Get function from the session.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.rpc.RPCSession.device" title="tvm.rpc.RPCSession.device"><code class="xref py py-obj docutils literal notranslate"><span class="pre">device</span></code></a>(dev_type[, dev_id])</p></td>
<td><p>Construct a remote device.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.rpc.RPCSession.upload" title="tvm.rpc.RPCSession.upload"><code class="xref py py-obj docutils literal notranslate"><span class="pre">upload</span></code></a>(data[, target])</p></td>
<td><p>Upload file to remote runtime temp folder</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.rpc.RPCSession.download" title="tvm.rpc.RPCSession.download"><code class="xref py py-obj docutils literal notranslate"><span class="pre">download</span></code></a>(path)</p></td>
<td><p>Download file from remote temp folder.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.rpc.RPCSession.remove" title="tvm.rpc.RPCSession.remove"><code class="xref py py-obj docutils literal notranslate"><span class="pre">remove</span></code></a>(path)</p></td>
<td><p>Remove file from remote temp folder.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.rpc.RPCSession.load_module" title="tvm.rpc.RPCSession.load_module"><code class="xref py py-obj docutils literal notranslate"><span class="pre">load_module</span></code></a>(path)</p></td>
<td><p>Load a remote module, the file need to be uploaded first.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.rpc.RPCSession.download_linked_module" title="tvm.rpc.RPCSession.download_linked_module"><code class="xref py py-obj docutils literal notranslate"><span class="pre">download_linked_module</span></code></a>(path)</p></td>
<td><p>Link a module in the remote and download it.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.rpc.RPCSession.cpu" title="tvm.rpc.RPCSession.cpu"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cpu</span></code></a>([dev_id])</p></td>
<td><p>Construct CPU device.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.rpc.RPCSession.cuda" title="tvm.rpc.RPCSession.cuda"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cuda</span></code></a>([dev_id])</p></td>
<td><p>Construct CUDA GPU device.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.rpc.RPCSession.cl" title="tvm.rpc.RPCSession.cl"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cl</span></code></a>([dev_id])</p></td>
<td><p>Construct OpenCL device.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.rpc.RPCSession.vulkan" title="tvm.rpc.RPCSession.vulkan"><code class="xref py py-obj docutils literal notranslate"><span class="pre">vulkan</span></code></a>([dev_id])</p></td>
<td><p>Construct Vulkan device.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.rpc.RPCSession.metal" title="tvm.rpc.RPCSession.metal"><code class="xref py py-obj docutils literal notranslate"><span class="pre">metal</span></code></a>([dev_id])</p></td>
<td><p>Construct Metal device.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.rpc.RPCSession.rocm" title="tvm.rpc.RPCSession.rocm"><code class="xref py py-obj docutils literal notranslate"><span class="pre">rocm</span></code></a>([dev_id])</p></td>
<td><p>Construct ROCm device.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.rpc.RPCSession.ext_dev" title="tvm.rpc.RPCSession.ext_dev"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ext_dev</span></code></a>([dev_id])</p></td>
<td><p>Construct extension device.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.rpc.RPCSession.hexagon" title="tvm.rpc.RPCSession.hexagon"><code class="xref py py-obj docutils literal notranslate"><span class="pre">hexagon</span></code></a>([dev_id])</p></td>
<td><p>Construct Hexagon device.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.rpc.RPCSession.webgpu" title="tvm.rpc.RPCSession.webgpu"><code class="xref py py-obj docutils literal notranslate"><span class="pre">webgpu</span></code></a>([dev_id])</p></td>
<td><p>Construct WebGPU device.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.RPCSession.system_lib">
<span class="sig-name descname"><span class="pre">system_lib</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.RPCSession.system_lib" title="永久链接至目标">¶</a></dt>
<dd><p>Get system-wide library module.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>module</strong> – The system-wide library module.</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p><a class="reference internal" href="runtime.html#tvm.runtime.Module" title="tvm.runtime.Module">runtime.Module</a></p>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">参见</p>
<p><a class="reference internal" href="runtime.html#tvm.runtime.system_lib" title="tvm.runtime.system_lib"><code class="xref py py-obj docutils literal notranslate"><span class="pre">tvm.runtime.system_lib</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.RPCSession.get_function">
<span class="sig-name descname"><span class="pre">get_function</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.RPCSession.get_function" title="永久链接至目标">¶</a></dt>
<dd><p>Get function from the session.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The name of the function</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>f</strong> – The result function.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>Function</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.RPCSession.device">
<span class="sig-name descname"><span class="pre">device</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.RPCSession.device" title="永久链接至目标">¶</a></dt>
<dd><p>Construct a remote device.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dev_type</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – </p></li>
<li><p><strong>dev_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – </p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>dev</strong> – The corresponding encoded remote device.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="runtime.html#tvm.runtime.Device" title="tvm.runtime.Device">Device</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.RPCSession.upload">
<span class="sig-name descname"><span class="pre">upload</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.RPCSession.upload" title="永久链接至目标">¶</a></dt>
<dd><p>Upload file to remote runtime temp folder</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#bytearray" title="(在 Python v3.10)"><em>bytearray</em></a>) – The file name or binary in local to upload.</p></li>
<li><p><strong>target</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – The path in remote</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.RPCSession.download">
<span class="sig-name descname"><span class="pre">download</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.RPCSession.download" title="永久链接至目标">¶</a></dt>
<dd><p>Download file from remote temp folder.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>path</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The relative location to remote temp folder.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>blob</strong> – The result blob from the file.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#bytearray" title="(在 Python v3.10)">bytearray</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.RPCSession.remove">
<span class="sig-name descname"><span class="pre">remove</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.RPCSession.remove" title="永久链接至目标">¶</a></dt>
<dd><p>Remove file from remote temp folder.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>path</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The relative location to remote temp folder.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.RPCSession.load_module">
<span class="sig-name descname"><span class="pre">load_module</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.RPCSession.load_module" title="永久链接至目标">¶</a></dt>
<dd><p>Load a remote module, the file need to be uploaded first.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>path</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The relative location to remote temp folder.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>m</strong> – The remote module containing remote function.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="runtime.html#tvm.runtime.Module" title="tvm.runtime.Module">Module</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.RPCSession.download_linked_module">
<span class="sig-name descname"><span class="pre">download_linked_module</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.RPCSession.download_linked_module" title="永久链接至目标">¶</a></dt>
<dd><p>Link a module in the remote and download it.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>path</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The relative location to remote temp folder.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>blob</strong> – The result blob from the file.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#bytearray" title="(在 Python v3.10)">bytearray</a></p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>This function can be helpful when a linker
is not available on the local client.</p>
</div>
<p class="rubric">实际案例</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">mod</span> <span class="o">=</span> <span class="n">build_module_with_cross_compilation</span><span class="p">()</span>
<span class="c1"># export the module as tar because a local linker is not available</span>
<span class="n">mod</span><span class="o">.</span><span class="n">export_library</span><span class="p">(</span><span class="s2">&quot;lib.tar&quot;</span><span class="p">)</span>
<span class="n">remote</span><span class="o">.</span><span class="n">upload</span><span class="p">(</span><span class="s2">&quot;lib.tar&quot;</span><span class="p">)</span>
<span class="c1"># invoke the linker on the remote to link the module as a library</span>
<span class="c1"># note that the library can only run on the same env as the remote</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">&quot;lib.so&quot;</span><span class="p">,</span> <span class="s2">&quot;wb&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="nb">file</span><span class="p">:</span>
    <span class="nb">file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">remote</span><span class="o">.</span><span class="n">download_linked_module</span><span class="p">(</span><span class="s2">&quot;lib.tar&quot;</span><span class="p">))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.RPCSession.cpu">
<span class="sig-name descname"><span class="pre">cpu</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.RPCSession.cpu" title="永久链接至目标">¶</a></dt>
<dd><p>Construct CPU device.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.RPCSession.cuda">
<span class="sig-name descname"><span class="pre">cuda</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.RPCSession.cuda" title="永久链接至目标">¶</a></dt>
<dd><p>Construct CUDA GPU device.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.RPCSession.cl">
<span class="sig-name descname"><span class="pre">cl</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.RPCSession.cl" title="永久链接至目标">¶</a></dt>
<dd><p>Construct OpenCL device.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.RPCSession.vulkan">
<span class="sig-name descname"><span class="pre">vulkan</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.RPCSession.vulkan" title="永久链接至目标">¶</a></dt>
<dd><p>Construct Vulkan device.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.RPCSession.metal">
<span class="sig-name descname"><span class="pre">metal</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.RPCSession.metal" title="永久链接至目标">¶</a></dt>
<dd><p>Construct Metal device.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.RPCSession.rocm">
<span class="sig-name descname"><span class="pre">rocm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.RPCSession.rocm" title="永久链接至目标">¶</a></dt>
<dd><p>Construct ROCm device.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.RPCSession.ext_dev">
<span class="sig-name descname"><span class="pre">ext_dev</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.RPCSession.ext_dev" title="永久链接至目标">¶</a></dt>
<dd><p>Construct extension device.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.RPCSession.hexagon">
<span class="sig-name descname"><span class="pre">hexagon</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.RPCSession.hexagon" title="永久链接至目标">¶</a></dt>
<dd><p>Construct Hexagon device.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.RPCSession.webgpu">
<span class="sig-name descname"><span class="pre">webgpu</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.RPCSession.webgpu" title="永久链接至目标">¶</a></dt>
<dd><p>Construct WebGPU device.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.rpc.LocalSession">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.rpc.</span></span><span class="sig-name descname"><span class="pre">LocalSession</span></span><a class="headerlink" href="#tvm.rpc.LocalSession" title="永久链接至目标">¶</a></dt>
<dd><p>RPCSession interface backed by local environment.</p>
<p>This class can be used to implement functions that
need to be ran both locally and remotely.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.rpc.PopenSession">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.rpc.</span></span><span class="sig-name descname"><span class="pre">PopenSession</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">binary</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.PopenSession" title="永久链接至目标">¶</a></dt>
<dd><p>RPCSession interface backed by popen.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>binary</strong> (<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><em>Union</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#bytes" title="(在 Python v3.10)"><em>bytes</em></a><em>]</em><em>]</em>) – The binary to be executed.</p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.rpc.TrackerSession">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.rpc.</span></span><span class="sig-name descname"><span class="pre">TrackerSession</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">addr</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.TrackerSession" title="永久链接至目标">¶</a></dt>
<dd><p>Tracker client session.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>addr</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(在 Python v3.10)"><em>tuple</em></a>) – The address tuple</p>
</dd>
</dl>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.rpc.TrackerSession.close" title="tvm.rpc.TrackerSession.close"><code class="xref py py-obj docutils literal notranslate"><span class="pre">close</span></code></a>()</p></td>
<td><p>Close the tracker connection.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.rpc.TrackerSession.summary" title="tvm.rpc.TrackerSession.summary"><code class="xref py py-obj docutils literal notranslate"><span class="pre">summary</span></code></a>()</p></td>
<td><p>Get the summary dict of the tracker.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.rpc.TrackerSession.text_summary" title="tvm.rpc.TrackerSession.text_summary"><code class="xref py py-obj docutils literal notranslate"><span class="pre">text_summary</span></code></a>()</p></td>
<td><p>Get a text summary of the tracker.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.rpc.TrackerSession.request" title="tvm.rpc.TrackerSession.request"><code class="xref py py-obj docutils literal notranslate"><span class="pre">request</span></code></a>(key[, priority, session_timeout, …])</p></td>
<td><p>Request a new connection from the tracker.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.rpc.TrackerSession.request_and_run" title="tvm.rpc.TrackerSession.request_and_run"><code class="xref py py-obj docutils literal notranslate"><span class="pre">request_and_run</span></code></a>(key, func[, priority, …])</p></td>
<td><p>Request a resource from tracker and run the func.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.TrackerSession.close">
<span class="sig-name descname"><span class="pre">close</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.TrackerSession.close" title="永久链接至目标">¶</a></dt>
<dd><p>Close the tracker connection.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.TrackerSession.summary">
<span class="sig-name descname"><span class="pre">summary</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.TrackerSession.summary" title="永久链接至目标">¶</a></dt>
<dd><p>Get the summary dict of the tracker.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.TrackerSession.text_summary">
<span class="sig-name descname"><span class="pre">text_summary</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.TrackerSession.text_summary" title="永久链接至目标">¶</a></dt>
<dd><p>Get a text summary of the tracker.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.TrackerSession.request">
<span class="sig-name descname"><span class="pre">request</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">key</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">priority</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">session_timeout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_retry</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">5</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">session_constructor_args</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.TrackerSession.request" title="永久链接至目标">¶</a></dt>
<dd><p>Request a new connection from the tracker.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>key</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The type key of the device.</p></li>
<li><p><strong>priority</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The priority of the request.</p></li>
<li><p><strong>session_timeout</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a><em>, </em><em>optional</em>) – The duration of the session, allows server to kill
the connection when duration is longer than this value.
When duration is zero, it means the request must always be kept alive.</p></li>
<li><p><strong>max_retry</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – Maximum number of times to retry before give up.</p></li>
<li><p><strong>session_constructor_args</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(在 Python v3.10)"><em>list</em></a><em>, </em><em>optional</em>) – List of additional arguments to passed as the remote session constructor.
The first element of the list is always a string specifying the name of
the session constructor, the following args are the positional args to that function.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.rpc.TrackerSession.request_and_run">
<span class="sig-name descname"><span class="pre">request_and_run</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">key</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">priority</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">session_timeout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_retry</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">2</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.TrackerSession.request_and_run" title="永久链接至目标">¶</a></dt>
<dd><p>Request a resource from tracker and run the func.</p>
<p>This function safe-guard rare server node dropout during execution.
In such case, a new resource will be requested and func will be ran again.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>key</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The type key of the device.</p></li>
<li><p><strong>func</strong> (<em>function of session -&gt; value</em>) – A stateless function</p></li>
<li><p><strong>priority</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The priority of the request.</p></li>
<li><p><strong>session_timeout</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a><em>, </em><em>optional</em>) – The duration of the session, allows server to kill
the connection when duration is longer than this value.
When duration is zero, it means the request must always be kept alive.</p></li>
<li><p><strong>max_retry</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – Maximum number of times to retry the function before give up.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.rpc.with_minrpc">
<span class="sig-prename descclassname"><span class="pre">tvm.rpc.</span></span><span class="sig-name descname"><span class="pre">with_minrpc</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">compile_func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">server</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'posix_popen_server'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">runtime</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'libtvm'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.rpc.with_minrpc" title="永久链接至目标">¶</a></dt>
<dd><p>Attach the compiler function with minrpc related options.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>compile_func</strong> (<em>Union</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Callable" title="tvm.relay.dataflow_pattern.Callable"><em>Callable</em></a><em>[</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>Optional</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em><em>]</em><em>, </em><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><em>None</em></a><em>]</em><em>]</em>) – The compilation function to decorate.</p></li>
<li><p><strong>server</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The server type.</p></li>
<li><p><strong>runtime</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The runtime library.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>fcompile</strong> – The return compilation.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>function</p>
</dd>
</dl>
</dd></dl>

</div>


           </div>
           
          </div>
          

<footer>

    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="micro.html" class="btn btn-neutral float-right" title="tvm.micro" accesskey="n" rel="next">下一个 <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="auto_scheduler.html" class="btn btn-neutral float-left" title="tvm.auto_scheduler" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> 上一个</a>
      
    </div>

<div id="button" class="backtop"><img src="../../../_static//img/right.svg" alt="backtop"/> </div>
<section class="footerSec">
    <div class="footerHeader">
      <ul class="d-flex align-md-items-center justify-content-between flex-column flex-md-row">
        <li class="copywrite d-flex align-items-center">
          <h5 id="copy-right-info">© 2020 Apache Software Foundation | All right reserved</h5>
        </li>
      </ul>

    </div>

    <ul>
      <li class="footernote">Copyright © 2020 The Apache Software Foundation. Apache TVM, Apache, the Apache feather, and the Apache TVM project logo are either trademarks or registered trademarks of the Apache Software Foundation.</li>
    </ul>

</section>
</footer>
        </div>
      </div>

    </section>

  </div>
  

    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

  </body>
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
    <!-- Theme Analytics -->
    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-75982049-2', 'auto');
    ga('send', 'pageview');
    </script>

    
   

</body>
</html>